//
//  IQWHttpEngine.h
//  117goFramework
//
//  Created by Yunhai.Wu on 15/7/29.
//  Copyright (c) 2015年 117go. All rights reserved.
//

#import <Foundation/Foundation.h>

@protocol IQWHttpRequest;
@protocol IQWHttpResponse;

/**
 *  回调block
 *
 *  @param res   http response
 *  @param error error
 */
typedef void(^WJHttpEngineResponseBlock)(id<IQWHttpResponse> res, NSError *error);

@protocol IQWHttpEngine <NSObject>

/**
 *  是否在请求中
 */
-(BOOL) hasLoading;

/**
 *  异步请求
 *
 *  @param request  http request
 *  @param resClass http response Class
 *  @param resBlock response block
 */
-(void) asynRequest:(id<IQWHttpRequest>) request responseClass:(Class) resClass responseBlock:(WJHttpEngineResponseBlock) resBlock;

/**
 *  同步请求(此请求只在main thread中请求，异步线程可能会有问题)
 *
 *  @param request  http request
 *  @param resClass http response Class
 *  @param error    error
 *
 *  @return http response
 */
-(id<IQWHttpResponse>) syncRequest:(id<IQWHttpRequest>) request responseClass:(Class) resClass error:(NSError**) error;

/**
 *  同步调用，不适用ASIHTTPRequest 或 AFNetworking
 *
 *  @param request  http request
 *  @param resClass http response Class
 *  @param error    error
 *
 *  @return http response
 */
-(id<IQWHttpResponse>) syncRequestSystem:(id<IQWHttpRequest>) request responseClass:(Class) resClass error:(NSError**) error;

@end
